public class test {
    public static void main(String[] args) {
        Employee []es = new Employee[4];
        es[0] = new SalariedEmployee("张三",2,5000);
        es[1] = new HourlyEmployee("李四",5,15,180);
        es[2] = new SalesEmployee("王五",7,10000,0.5);
        es[3] = new BasePlusSalesEmployee("孙六",9,9000,0.5,1000);
        for(int i = 0;i < 4;i++) {
                System.out.println(es[i].getName() + "5月的工资为" + es[i].getSalary(5));
        }
    }
}
class Employee {
    private String name;
    private int birthmonth;//员工生日月份
    public Employee(String name,int birthmonth) {
        this.name = name;
        this.birthmonth = birthmonth;
    }
    public double getSalary(int month) {
        if(birthmonth == month) {
            return 100;
        }
        else {
            return 0;
        }
    }
    public String getName() {
        return name;
    }
}
class SalariedEmployee extends Employee {
    private int monthsalary;//月薪
    public SalariedEmployee(String name,int birthmonth,int monthsalary) {
        super(name,birthmonth);
        this.monthsalary = monthsalary;
    }
    public double getSalary(int month) {
        return monthsalary + super.getSalary(month);
    }
}
class HourlyEmployee extends Employee {
    private int hoursalary;//每小时的工资
    private int workhours;//每月工作的小时数
    public HourlyEmployee(String name,int birthmonth,int hoursalary,int workhours) {
        super(name,birthmonth);
        this.hoursalary = hoursalary;
        this.workhours = workhours;
    }
    public double getSalary(int month) {
        if(workhours > 160) {
            return 160 * hoursalary + (workhours - 160) * 1.5 * hoursalary + super.getSalary(month);
        }
        else {
            return workhours * hoursalary + super.getSalary(month);
        }
    }
}
class SalesEmployee extends Employee {
    private int salesnums;//月销售额
    private double rate;//提成率
    public SalesEmployee(String name,int birthmonth,int salesnums,double rate) {
        super(name,birthmonth);
        this.salesnums = salesnums;
        this.rate = rate;
    }
    public double getSalary(int month) {
        return salesnums * rate + super.getSalary(month);
    }
}
class BasePlusSalesEmployee extends SalesEmployee{
    private int basicsalary;//底薪
    public BasePlusSalesEmployee(String name,int birthmonth,int salesnums,double rate,int basicsalary) {
        super(name,birthmonth,salesnums,rate);
        this.basicsalary = basicsalary;
    }
    public double getSalary(int month) {
        return super.getSalary(month) + basicsalary;
    }
}